package com.ruoyi.business.projectRecord.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.projectRecord.domain.ProjectRecord;
import com.ruoyi.business.projectRecord.mapper.ProjectRecordMapper;
import com.ruoyi.business.projectRecord.service.ProjectRecordService;
import com.ruoyi.business.projectTosView.domain.VProjectTos;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 80661
* @description 针对表【PROJECT_RECORD】的数据库操作Service实现
* @createDate 2023-07-05 10:42:16
*/
@Service
public class ProjectRecordServiceImpl extends ServiceImpl<ProjectRecordMapper, ProjectRecord>
		implements ProjectRecordService {
	/**
	 * 单个bean：转化projectTosView为projectRecord
	 *
	 * @param projectTosView
	 */
	@Override
	public ProjectRecord convertProjectTosViewToProjectRecord(VProjectTos projectTosView) {
		// 创建ProjectRecord对象
		ProjectRecord projectRecord = new ProjectRecord();
		// 使用BeanUtils.copyProperties()方法进行转化
		BeanUtils.copyProperties(projectTosView, projectRecord);
		// 返回结果
		return projectRecord;
	}
	
	/**
	 * list：转化projectTosView为projectRecord
	 *
	 * @param projectTosViewList
	 */
	@Override
	public List<ProjectRecord> convertProjectTosViewToProjectRecord(List<VProjectTos> projectTosViewList) {
		// 创建ProjectRecord对象List
		List<ProjectRecord> projectRecordList = new ArrayList<>();
		// 遍历projectTosViewList 每一个元素都转化为ProjectRecord对象
		for (VProjectTos projectTosView : projectTosViewList) {
			ProjectRecord projectRecord = this.convertProjectTosViewToProjectRecord(projectTosView);
			projectRecordList.add(projectRecord);
		}
		// 返回结果
		return projectRecordList;
	}
}




